package com.sec.web;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;
import com.sec.pojo.User;
import com.sec.service.UserService;

@Namespace(value = "/work")
public class UserAction extends ActionSupport {
	private static final long serialVersionUID = 8907605561460172723L;

	@Resource(name = "userService")
	private UserService userService;

	private User userReg;

	public User getUserReg() {
		return userReg;
	}

	public void setUserReg(User userReg) {
		this.userReg = userReg;
	}

	@Action(value = "user", results = {
			@Result(name = "success", location = "/WEB-INF/page/success.jsp"),
			@Result(name = "error", location = "/WEB-INF/page/error.jsp"),
			@Result(name = "input", location = "/WEB-INF/page/register.jsp") })
	public String register() {
		userReg = userService.register(userReg);
		if (null != userReg) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	public void test() {
		System.out.println("test_hello");

	}

}
